package idiet.dao.hibernate;

import idiet.bean.CustomerNurseTrace;

import java.io.Serializable;
import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository("customerNurseTraceDao")
public class CustomerNurseTraceDao extends BaseDao {
	public CustomerNurseTrace getCustomerNurseTraceById(int customerNurseTraceId){
		return (CustomerNurseTrace) this.sessionFactory
				.getCurrentSession()
				.get(CustomerNurseTrace.class, customerNurseTraceId);
				/*.createCriteria(CustomerNurseTrace.class)
				.add(Restrictions.eq("id", customerNurseTraceId))
				.uniqueResult();*/
	}
	/*public CustomerNurseTrace getCustomerNurseTrace(int id){
		return (CustomerNurseTrace) this.sessionFactory.getCurrentSession()
				.get(CustomerNurseTrace.class, id);
	}*/
	@SuppressWarnings("unchecked")
	public List<CustomerNurseTrace> getCustomerNurseTracesByCustomerNurseTraceName(String name){
		return this.sessionFactory
				.getCurrentSession()
				.createCriteria(CustomerNurseTrace.class)
				.add(Restrictions.like("name",name))
				.list();
	}
	@SuppressWarnings("unchecked")
	public List<CustomerNurseTrace> getCustomerNurseTraces(){
		return this.sessionFactory
				.getCurrentSession()
				.createCriteria(CustomerNurseTrace.class)
				.list();
	}
	public void createCustomerNurseTrace(CustomerNurseTrace customerNurseTrace){
		this.sessionFactory
		.getCurrentSession()
		.save(customerNurseTrace);
	}
	public void updateCustomerNurseTrace(CustomerNurseTrace customerNurseTrace){
		this.sessionFactory
		.getCurrentSession()
		.update(customerNurseTrace);
	}
	public void deleteCustomerNurseTrace(CustomerNurseTrace customerNurseTrace){
		this.sessionFactory
		.getCurrentSession()
		.delete(customerNurseTrace);
	}
}
